package com.ymx.darling.wrapper.fragment;

import com.ymx.darling.bean.sql.SqlStatement;

import java.util.ArrayList;

public class UnionSegment implements SqlSegment {
    private final StringBuilder unionBuilder = new StringBuilder();

    @Override
    public SqlStatement getSqlStatement(){
        String sql = this.unionBuilder.toString();
        return new SqlStatement(sql, new ArrayList<>());
    }

    public void union(String queryWrapperPlaceholder){
        this.unionBuilder.append(" UNION ").append(queryWrapperPlaceholder);
    }

    public void unionAll(String queryWrapperPlaceholder){
        this.unionBuilder.append(" UNION ALL ").append(queryWrapperPlaceholder);
    }
}
